/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package chat01;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

/**
 * <p>Project: jse2204 - Client
 * <p>Powered by webrx On 2022-09-29 14:50:57
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Client {
    public static void main(String[] args) {
        //客户端
        try{
            Socket c = new Socket("192.168.13.249",8080);
            PrintWriter out = new PrintWriter(c.getOutputStream()); //发信息
            BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream())); //接信息
            while(true) {
                //发信息
                System.out.println("发信息：");
                String msg = new Scanner(System.in).nextLine() + "\r\n";
                out.write(msg);
                out.flush();

                //先收信息
                String info = br.readLine();
                System.out.println(info);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
